package com.woniuxy.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.daos.TbComplaintDao;
import com.woniuxy.entitys.TbComplaint;
import com.woniuxy.entitys.TbComplaintExample;
import com.woniuxy.entitys.TbCustomer;
import com.woniuxy.services.ComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Classname ComplaintServiceImpl
 * @Date 2024/1/14 17:13
 */
@Service
public class ComplaintServiceImpl implements ComplaintService {
    @Autowired
    private TbComplaintDao complaintDao;
    @Override
    public PageInfo<TbComplaint> getAllComplaints(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbComplaint> tbComplaints = complaintDao.selComplaints();
        PageInfo<TbComplaint> tbComplaintPageInfo = new PageInfo<>(tbComplaints);
        return tbComplaintPageInfo;
    }

    @Override
    public int updateSoftdel(Integer tcid) {
        int i =complaintDao.updateFlag(tcid);
        return i;
    }

    @Override
    public PageInfo<TbComplaint> getByCondition(Integer pageNum, Integer pageSize, Date beginTime, Date endTime) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbComplaint> list = complaintDao.selByCondition(beginTime,endTime);
        PageInfo<TbComplaint> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int updateComplaint(Integer tcid) {
        return complaintDao.updateComplaintFlag(tcid);
    }

    @Override
    public PageInfo<TbComplaint> getComplaintsByCid(Integer pageNum, Integer pageSize, Integer cid) {
        PageHelper.startPage(pageNum,pageSize);
        List<TbComplaint> list = complaintDao.selByCidAndFlag(cid);
        PageInfo<TbComplaint> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int saveOne(TbComplaint tbComplaint) {
        return complaintDao.insert(tbComplaint);
    }

    @Override
    public int softdel(TbComplaint tbComplaint) {
        return complaintDao.updateByPrimaryKeySelective(tbComplaint);
    }
}
